<?php

namespace App\Utils;

use Illuminate\Http\Request;

class GenObjFromRequestUtil
{
    /**
     * @param string $dest
     * @param Request $request
     * @return mixed
     */
    public static function getObj(string $dest, Request $request)
    {
        $obj = new $dest();
        foreach ($obj as $key => $value) {
            $ret = $request->input($key);
            if ($ret || ($ret == '0')) {
                $obj->{$key} = $ret;
            }
        }
        return $obj;
    }
}
